package erlport.terms;


// see: http://erlang.org/doc/apps/erts/erl_ext_dist.html
enum Tag {

    // +-----+-----+
    // | 1   | 1   |
    // | 97  | Int |
    // +-----+-----+
    SMALL_INTEGER   (97),

    // +-----+-----+
    // | 1   | 4   |
    // | 98  | Int |
    // +-----+-----+
    INTEGER         (98),

    // +-----+--------------+
    // | 1   | 31           |
    // | 99  | Float string |
    // +-----+--------------+
    FLOAT           (99),

    // +------+-------+-----+-----------+
    // | 1    | N     | 4   | 1         |
    // | 102  | Node  | ID  | Creation  |
    // +------+-------+-----+-----------+
    PORT            (102),

    // +------+-------+-----+-----------+
    // | 1    | N     | 4   | 4         |
    // | 89   | Node  | ID  | Creation  |
    // +------+-------+-----+-----------+
    NEW_PORT        (89),

    // +------+-------+-----+--------+-----------+
    // | 1    | N     | 4   | 4      | 1         |
    // | 103  | Node  | ID  | Serial | Creation  |
    // +------+-------+-----+--------+-----------+
    PID             (103),

    // +------+-------+-----+--------+-----------+
    // | 1    | N     | 4   | 4      | 4         |
    // | 88   | Node  | ID  | Serial | Creation  |
    // +------+-------+-----+--------+-----------+
    NEW_PID          (88),

    // +------+-------+-----------+
    // | 1    | 1     | N         |
    // | 104  | Arity | Elements  |
    // +------+-------+-----------+
    SMALL_TUPLE     (104),

    // +------+-------+-----------+
    // | 1    | 4     | N         |
    // | 105  | Arity | Elements  |
    // +------+-------+-----------+
    LARGE_TUPLE     (105),

    // +------+-------+-----------+
    // | 1    | 4     | N         |
    // | 116  | Arity | Pairs     |
    // +------+-------+-----------+
    MAP             (116),

    // +------+
    // | 1    |
    // | 106  |
    // +------+
    NIL             (106),  // That is '[]'

    // +------+--------+------------+
    // | 1    | 2      | Len        |
    // | 107  | Length | Characters |
    // +------+--------+------------+
    STRING          (107),

    // +------+--------+------------+------+
    // | 1    | 4      |            |      |
    // | 108  | Length | Elements   | Tail |
    // +------+--------+------------+------+
    LIST            (108),

    // +------+--------+------------+
    // | 1    | 4      | Len        |
    // | 109  | Len    | Data       |
    // +------+--------+------------+
    BINARY          (109),

    // +------+----+------+-----------------+
    // | 1    | 1  | 1    | n               |
    // | 110  | n  | Sign | d(0) ... d(n-1) |
    // +------+----+------+-----------------+
    SMALL_BIG       (110),

    // +------+----+------+-----------------+
    // | 1    | 4  | 1    | n               |
    // | 111  | n  | Sign | d(0) ... d(n-1) |
    // +------+----+------+-----------------+
    LARGE_BIG       (111),

    // +------+-------+-----+-----------+
    // | 1    | N     | 4   | 1         |
    // | 101  | Node  | ID  | Creation  |
    // +------+-------+-----+-----------+
    REFERENCE       (101),  // deprecated

    // +------+-----+------+-----------+--------+
    // | 1    | 2   | N    | 1         | N'     |
    // | 114  | Len | Node | Creation  | ID ... |
    // +------+-----+------+-----------+--------+
    NEW_REFERENCE   (114),

    // +------+-----+------+-----------+--------+
    // | 1    | 2   | N    | 4         | N'     |
    // | 90   | Len | Node | Creation  | ID ... |
    // +------+-----+------+-----------+--------+
    NEWER_REFERENCE (90),

    // +------+---------+-----+-------+-------+------+---------------+
    // | 1    | 4       | N1  | N2    | N3    | N4   | N5            |
    // | 117  | NumFree | Pid | Module| Index | Uniq | Free vars ... |
    // +------+---------+-----+-------+-------+------+---------------+
    FUN             (117),

    // +------+------+-------+------+-------+---------+-----+-------+-------+------+---------------+
    // | 1    | 4    | 1     | 16   | 4     |  4      | N1  | N2    | N3    | N4   | N5            |
    // | 112  | Size | Arity | Uniq | Index | NumFree | Pid | Module| Index | Uniq | Free vars ... |
    // +------+------+-------+------+-------+---------+-----+-------=-------+------+---------------+
    NEW_FUN         (112),

    // +------+--------+----------+-------+
    // | 1    | N1     | N2       | N3    |
    // | 113  | Module | Function | Arity |
    // +------+--------+----------+-------+
    EXPORT          (113), 

    // +------+------+------+-------+
    // | 1    | 4    | 1    | Len   |
    // | 77   | Len  | Bits | Data  |
    // +------+------+------+-------+
    BIT_BINARY      (77),

    // +------+------------+
    // | 1    | 8          |
    // | 70   | IEEE float |
    // +------+------------+
    NEW_FLOAT       (70),

    // +------+-----+----------+
    // | 1    | 2   | Len      |
    // | 118  | Len | AtomName |
    // +------+-----+----------+
    ATOM_UTF8       (118),

    // +------+-----+----------+
    // | 1    | 1   | Len      |
    // | 119  | Len | AtomName |
    // +------+-----+----------+
    SMALL_ATOM_UTF8 (119),

    // +------+-----+----------+
    // | 1    | 2   | Len      |
    // | 100  | Len | AtomName |
    // +------+-----+----------+
    ATOM            (100),     // deprecated

    // +------+-----+----------+
    // | 1    | 1   | Len      |
    // | 115  | Len | AtomName |
    // +------+-----+----------+
    SMALL_ATOM      (115),


    DIST_NORMAL     (68),
    DIST_FRAGMENTED (69);

    private int value;

    private Tag(int x) {
        this.value = x;
    }
}
